
public class hanoi {
    public static void hanoi1(int n, char post1, char post2, char post3) {
        if (n == 1) {
            move(post1, post3);
            return;
        }
        hanoi1(n - 1, post1, post3, post2);
        move(post1, post3);
        hanoi1(n - 1, post2, post1, post3);
    }

    public static void move(char post1, char post2) {
        System.out.println(post1 + "->" + post2 + " ");
    }

    public static void main(String[] args) {
        hanoi1(3,'A','B','C');
    }
}

